/*
 * Copyright 2008 Max Kugland
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.splink.library.queue {

	/**
	 * Defines a progress object
	 * 
	 * @author Max Kugland
	 */
	public class Progress {
		public var current : Number;
		public var total : Number;
		
		/**
		 * @param current the current value
		 * @param total the total value
		 */
		public function Progress(current : Number, total : Number) {
			this.current = current;
			this.total = total;
		}
		
		/**
		 * @return the current progress in percent
		 */
		public function get percent() : uint {
			return Math.round(Math.min(100, current / total * 100));
		}
		
		/**
		 * @return a <code>String</code> representation
		 */
		public function toString() : String {
			return percent + "% " + current + " / " + total;
		}
		
		/**
		 * @return a clone of this <code>Progress</code> instance
		 */
		public function clone() : Progress {
			return new Progress(current, total);
		}
	}
}
